<template>
  <div class="salesTrendYear">
    <div class="title">
      <stitle :bg="bg" text="年销售趋势图" :type="0" />
    </div>
    <div id="echartSalesTrendYear"></div>
  </div>
</template>

<script>
import stitle from "@/components/common/stitle";
import store from "@/utils/store";
export default {
  name: "salesTrendYear",
  components: {
    stitle,
  },
  data() {
    return {
      bg: require("@/assets/images/DispatchCommand/stitle.png"),
    };
  },
  mounted() {
    this.setEchart();
  },
  methods: {
    setEchart() {
      const _echarts = this.$echarts.init(
        document.getElementById("echartSalesTrendYear")
      );
      const option = {
        grid: {
          bottom: "15%",
          right: "10%",
          top: "15%",
        },
        tooltip: {
          trigger: "axis",
          textStyle: {
            fontSize: 14,
            heigth: 50,
            width: 50,
          },
        },
        xAxis: {
          type: "category",
          data: [
            "2014",
            "2015",
            "2016",
            "2017",
            "2018",
            "2019",
            "2020",
            "2021",
            "2022",
          ],
          axisLine: {
            lineStyle: {
              color: "#fff",
            },
          },
          axisLabel: {
            textStyle: {
              color: "#fff",
              fontSize: 12,
            },
          },
        },
        yAxis: {
          type: "value",
          name: "( 万元 )",
          axisLabel: {
            formatter: "{value}",
            textStyle: {
              color: "#fff",
              fontSize: 12,
            },
          },
          axisLine: {
            lineStyle: {
              color: "#fff",
            },
          },
          splitLine: {
            show: true,
            lineStyle: {
              color: ["#305383"],
              width: 1,
              type: "solid",
            },
          },
        },
        series: [
          {
            data: [38, 41, 25, 33, 31, 59, 69, 50, 56, 27, 54],
            type: "line",
            itemStyle: {
              color: "#00FFFF",
            },
            lineStyle: {
              color: "#00FFFF",
            },
            areaStyle: {
              color: {
                type: "linear",
                x: 0,
                y: 0,
                x2: 0,
                y2: 1,
                colorStops: [
                  {
                    offset: 0,
                    color: "rgba(0, 255, 255, 1)", // 0% 处的颜色
                  },
                  {
                    offset: 1,
                    color: "rgba(0, 255, 255, 0)", // 100% 处的颜色
                  },
                ],
                global: false, // 缺省为 false
              },
            },
            smooth: true,
          },
        ],
      };
      _echarts.setOption(option);
    },
  },
};
</script>

<style lang="scss" scoped>
.salesTrendYear {
  width: 500px;
  height: 250px;
  margin-left: 20px;
  float: left;
  .title {
    width: 400px;
  }
  #echartSalesTrendYear {
    width: 100%;
    height: 230px;
  }
}
</style>
